package com.cn.wanxi.util;

public class Tool {
    private Tool() {

    }

    public static String nullToString(String value) {
        return value == null ? "" : value;
    }

    public static int stringToInt(String value) {
        try {
            return Integer.parseInt(value);
        } catch (Exception e) {
            return -1;
        }
    }

    public static Double stringToDouble(String value) {
        try {
            return Double.parseDouble(value);
        } catch (Exception e) {
            return 0.0;
        }
    }

    public static Float stringToFloat(String value) {
        try {
            return Float.parseFloat(value);
        } catch (Exception e) {
            return 0.0F;
        }
    }

    public static int curPageToInt(String value) {
        try {
            return Integer.parseInt(value);
        } catch (Exception e) {
            return 1;
        }
    }

    public static int pageSizeToInt(String value) {
        try {
            return Integer.parseInt(value);
        } catch (Exception e) {
            return 10;
        }
    }
}
